package com.example.demo.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import com.example.demo.dto.SearchInfo;
import com.example.demo.entity.Medicineuse;

@Repository()
public interface Medicineuse_Mapper extends BaseMapper<Medicineuse>{
	@Select("select medicineuse.*, doctor.name doctor_name, patient.name patient_name "
	        + "from medicineuse "
	        + "inner join doctor on medicineuse.doctor_id = doctor.id "
	        + "inner join patient on medicineuse.patient_id = patient.id "
	        + "${where} ${limitstr}")
	public List<Medicineuse> select(SearchInfo info);
	
	@Select("select count(1) from medicineuse "
	        + "inner join doctor on medicineuse.doctor_id = doctor.id "
	        + "inner join patient on medicineuse.patient_id = patient.id "
	        + "${where}")
	public long selectCount(SearchInfo info);
	
	
	@Insert("insert into medicineuse (name,description,doctor_id,patient_id,num) values(#{name},#{description},#{doctor_id},#{patient_id},#{num})")
	public void insert (Medicineuse m);
	
	@Update("update medicineuse set name=#{name},description=#{description},patient_id=#{patient_id},doctor_id=#{doctor_id},num=#{num} where id=#{id}")
	public void update (Medicineuse m);
	
	@Select("delete from medicineuse where id=#{id}")
	public void delete(int id);
	
	@Select("select * from medicineuse where id=#{id} ")
	public Medicineuse selectById(int id);
	
	
}
